/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.ro.model.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 
 * @author L842359
 */
@Entity
@Table(name = "usuario")
public class Usuario implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "id")
	private Integer id;
	@Column(name = "nome")
	private String nome;
	@Column(name = "login")
	private String login;
	@Column(name = "password")
	private String password;
	@Column(name = "email")
	private String email;
	@Column(name = "telefone")
	private String telefone;
	@ManyToMany(mappedBy = "usuarioList", fetch = FetchType.EAGER)
	private List<Projeto> projetoList;
	@JoinColumn(name = "grupo_id", referencedColumnName = "id")
	@ManyToOne(optional = false)
	private Grupo grupoId;
	@JoinColumn(name = "perfil_id", referencedColumnName = "id")
	@ManyToOne(optional = false)
	private Perfil perfilId;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "usuarioId")
	private List<Historico> historicoList;

	public Usuario() {
	}

	public Usuario(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getTelefone() {
		return telefone;
	}

	public void setTelefone(String telefone) {
		this.telefone = telefone;
	}

	public List<Projeto> getProjetoList() {
		return projetoList;
	}

	public void setProjetoList(List<Projeto> projetoList) {
		this.projetoList = projetoList;
	}

	public Grupo getGrupoId() {
		return grupoId;
	}

	public void setGrupoId(Grupo grupoId) {
		this.grupoId = grupoId;
	}

	public Perfil getPerfilId() {
		return perfilId;
	}

	public void setPerfilId(Perfil perfilId) {
		this.perfilId = perfilId;
	}

	public List<Historico> getHistoricoList() {
		return historicoList;
	}

	public void setHistoricoList(List<Historico> historicoList) {
		this.historicoList = historicoList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof Usuario)) {
			return false;
		}
		Usuario other = (Usuario) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "br.com.ro.model.entity.Usuario[ id=" + id + " ]";
	}

}
